import javax.media.opengl.glu.GLU;
import javax.media.opengl.glu.GLUquadric;


/**
 * Extends genericGlObject with Sphere.
 *       Created 27/apr/2013.
 * @author Pietro Bolognesi matr. 227383
 * @author Giorgio Lazzaretti matr. 220232
 *  
 */
public class GlSphere extends GenericGlObject {
	/**
	 * Radius of the Sphere.
	 */
	protected float Radius = 0.1f;
	/**
	 * Number of slices.
	 */
	protected int Slices = 32;
	/**
	 * Number of Stacks.
	 */
	protected int Stacks = 16;
	
	//Setter e getter
	
	/**
	 * Returns the radius of the sphere.
	 *
	 * @return Radius.
	 */
	public float GetRadius(){return this.Radius;}
	/**
	 * Returns the number of slices of the sphere.
	 *
	 * @return Slices.
	 */
	public int GetSlices(){return this.Slices;}
	/**
	 * Returns the number of stacks of the sphere.
	 *
	 * @return Stacks.
	 */
	public int GetStacks(){return this.Stacks;}
	
	/**
	 * Set the radius of the sphere.
	 *
	 * @param r Radius.
	 */
	public void SetRadius( float r){ this.Radius = r;}
	/**
	 * Set the number of slices of the sphere.
	 * @param s Slices.
	 */
	public void SetSlices( int s){ this.Slices = s;}
	/**
	 * Set the numbero of stacks of the sphere.
	 * @param s Stacks.
	 */
	public void SetStacks( int s){ this.Stacks = s;}
	
	/**
	 * Create a new sphere.
	 *
	 */
	public GlSphere(){
		this.type = OBJType.SPHERE;
		this.ObjectName = "Sphere";
	}

	/**
	 * Draw the sphere.
	 *
	 */
	@Override
	public void DrawObject(){
		if(!IsToDraw())
			return;
		this.gl.glColor3f(this.Red, this.Green, this.Blue); // Settaggio del colore
		GLU glu = new GLU();
		GLUquadric quadric = glu.gluNewQuadric();
		glu.gluSphere(quadric , this.Radius, this.Slices, this.Stacks); // Disegno della sfera
	}
}
